package com.kaspersky.kaspresso.device.exploit

import com.kaspersky.kaspresso.annotations.RequiresAdbServer

/**
 * The interface for exploitation.
 *
 * Required: Started AdbServer
 *     1. Download a file "kaspresso/artifacts/adbserver-desktop.jar"
 *     2. Start AdbServer => input in cmd "java jar path_to_file/adbserver-desktop.jar"
 * Methods demanding to use AdbServer in the default implementation of this interface are marked.
 *     But nobody can't deprecate you to write implementation that doesn't require AdbServer.
 */
interface Exploit {

    /**
     * Toggles the orientation of the device.
     */
    @RequiresAdbServer
    fun rotate()

    /**
     * Sets the specific [DeviceOrientation] of the device.
     *
     * Required Permissions: INTERNET.
     *
     * @param deviceOrientation the desired orientation of the device.
     */
    @RequiresAdbServer
    fun setOrientation(deviceOrientation: DeviceOrientation)

    /**
     * Sets the device's auto-rotation, whether it is enabled or not, via shell.
     *
     * Required Permissions: INTERNET.
     *
     * @param enabled the desired auto-rotation state.
     */
    @RequiresAdbServer
    fun setAutoRotationEnabled(enabled: Boolean)

    /**
     * Presses back button on the device.
     *
     * @param failTestIfAppUnderTestClosed if set to true, an exception will be thrown when Espresso navigates
     * outside the application or process under test.
     */
    fun pressBack(failTestIfAppUnderTestClosed: Boolean = false)

    /**
     * Presses home button on the device.
     *
     * @return true if successful, else return false.
     */
    fun pressHome(): Boolean

    enum class DeviceOrientation {
        Portrait,
        Landscape
    }
}
